#ifndef __websocket
#define __websocket
#include "http.h"

#include <windows.h>
#include "App.h"
#include "looper.h"
#include "rapidjson/document.h"

const char *c_dhs_version = "dhs_version";
const char *c_dhs_design = "dhs_design";
const char *c_dhs_print = "dhs_print";
const char *c_dhs_show = "dhs_show";
const char *c_dhs_exportpdf = "dhs_exportpdf";
const char *c_dhs_image_dir = "dhs_image_dir";
const char *urlList_token = "urlList";
const char *jsonDbData_token = "jsonDbData";
const char *template_token = "template";
const char *copys_token = "copys";

const char *reportData_token = "reportData";
const char *uuid_token = "uuid";
const char *server_uuid_token = "server_uuid";
const char *command_token = "command";
const char *data_token = "data";

const char *data_type = "A_type";
//
const char *type_return_status = "save_status";
const char *type_command = "command";
const char *type_connect = "connect";
const char *type_save_call = "save_call";
const char *type_command_end = "command_end";
const char *type_error = "error";

BEGIN_DECAL_C

typedef uWS::WebSocket<false, true, uint64_t> session_t;

typedef struct user_data_context_s
{
    uint64_t uuid;
    uint64_t server_uuid;
    // session_t * ws;
} user_data_context_t;

user_data_context_t *allocate_user_data_context();
void free_user_data_context(user_data_context_t *context);

typedef bool(__cdecl *tcallback)(const char *report, user_data_context_t *userprivate);

//  DHS_API bool __cdecl  downStaticFile (const char*);

typedef void(__cdecl *showreport_t)(const char *, const char *);
typedef void(__cdecl *printreport_t)(const char *, const char *, const int);
typedef void(__cdecl *designreport_t)(const char *, const char *, tcallback cb, void *userprivate);
typedef void(__cdecl *exportpdf_t)(const char *, const char *, int isbase64, tcallback cb, void *userprivate);

designreport_t dhs_designreport = nullptr;
printreport_t dhs_printreport = nullptr;
showreport_t dhs_showreport = nullptr;
exportpdf_t dhs_exportpdf = nullptr;

DHS_API void app_init(designreport_t designreport, printreport_t printreport, showreport_t showreport, exportpdf_t exportpdf);

void runApp();
END_DECAL_C

void proccessMessage(session_t *session, std::string_view msg, user_data_context_t *context);

#endif
